// DlgDenoiserParam.cpp : implementation file
//

#include "stdafx.h"
#include "Public.h"
#include "PanImage.h"
#include "DlgDenoiserParam.h"


// CDlgDenoiserParam dialog

IMPLEMENT_DYNAMIC(CDlgDenoiserParam, CDialog)

CDlgDenoiserParam::CDlgDenoiserParam(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgDenoiserParam::IDD, pParent)
{

}

CDlgDenoiserParam::~CDlgDenoiserParam()
{
}

void CDlgDenoiserParam::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CDlgDenoiserParam, CDialog)
	ON_BN_CLICKED(IDC_BUTTON_OK, &CDlgDenoiserParam::OnBnClickedButtonOk)
	ON_BN_CLICKED(IDC_BUTTON_CANCEL, &CDlgDenoiserParam::OnBnClickedButtonCancel)
END_MESSAGE_MAP()


// CDlgDenoiserParam message handlers

void CDlgDenoiserParam::OnBnClickedButtonOk()
{
	char strText[124] = {0};
	GetDlgItemText(IDC_EDIT_DenoiserK1,strText,80);  g.xCapBaseCfg.xDynDenoiser.fK1 = atof(strText);
	GetDlgItemText(IDC_EDIT_DenoiserK2,strText,80);  g.xCapBaseCfg.xDynDenoiser.fK2 = atof(strText);
	GetDlgItemText(IDC_EDIT_DenoiserGrade1,strText,80);  g.xCapBaseCfg.xDynDenoiser.nGrade1 = _tstol(strText);
	GetDlgItemText(IDC_EDIT_DenoiserGrade2,strText,80);  g.xCapBaseCfg.xDynDenoiser.nGrade2 = _tstol(strText);
	WriteCfgFile((void*)&g.xCapBaseCfg,sizeof(g.xCapBaseCfg),"CapBaseConfig.bin");
	g.ViewDynamic->LoadDynDenoiserParam();
	CDialog::EndDialog(0);
}

void CDlgDenoiserParam::OnBnClickedButtonCancel()
{
	CDialog::EndDialog(0);
}
BOOL CDlgDenoiserParam::OnInitDialog()
{
	CDialog::OnInitDialog();
	char sText[50];
	Safesprintf(sText,_T("%g"),g.xCapBaseCfg.xDynDenoiser.fK1);
	SetDlgItemText(IDC_EDIT_DenoiserK1, sText);
	Safesprintf(sText,_T("%g"),g.xCapBaseCfg.xDynDenoiser.fK2);
	SetDlgItemText(IDC_EDIT_DenoiserK2, sText);
	Safesprintf(sText,_T("%d"),g.xCapBaseCfg.xDynDenoiser.nGrade1);
	SetDlgItemText(IDC_EDIT_DenoiserGrade1, sText);
	Safesprintf(sText,_T("%d"),g.xCapBaseCfg.xDynDenoiser.nGrade2);
	SetDlgItemText(IDC_EDIT_DenoiserGrade2, sText);

	return TRUE ;
}